package ErrorView;

use strict;

use Athena::WebAPI::HTML;
use Athena::WebAPI::Form;
use Athena::WebAPI::Table;
use Athena::WebAPI::View;

use Athena::NavHeaderView;

use base ("View");

sub new {

    # Get the class name
    my $stInvocant = shift(@_);
    my $stClass = ref($stInvocant) || $stInvocant;

    # Create the current instance and bless into class
    my $rSelf = { };
    bless($rSelf,$stClass);

    my %hParams = ( @_ );
    $rSelf->{params} = \%hParams;

    return $rSelf;
}

sub draw {
  my $rSelf = shift(@_);
  my $rParams = $rSelf->{params};

  my $rTable = Table->new(%{$rSelf->{params}->{table_style}});
  $rTable->addChild(0, 0, NavHeaderView->new($rSelf->{params}));
  $rTable->addChild(1, 0, 
		    "Error: " . $rSelf->{params}->{err_msg},
		    -bgcolor=>"#ddcccc");
  $rTable->addChild(2, 0, 
		    $rSelf->{params}->{err_body},
		    -bgcolor=>"#ddcccc");

  my $rForm = Form->new(-method=>'post');
  $rForm->addChild($rTable);
  $rForm->addHiddenFields($rParams->{'hidden_fields'});

  my $rHTML  = HTML->new();
  $rHTML->setBodyAttr(%{$rSelf->{params}->{body_style}});
  $rHTML->addChild($rForm);
  
  return $rHTML->draw();
}

1;
